package java1;

import java.util.Scanner;

class IllegalScoreException extends Exception{
	public IllegalScoreException(String msg){
		super(msg);
	}
}
class IllegalNameException extends Exception{
	public IllegalNameException(String msg){
		super(msg);
	}
}
class Student{
	private String name;
	private int score;
	public String getName() {
		return name;
	}
	public Student(String name) throws IllegalNameException {
		 if (Character.isDigit(name.charAt(0)))
			 throw new IllegalNameException("the first char of name must not be digit, name="+name);
		this.name = name;
	}
	@Override
	public String toString() {
		return "Stduent [name=" + name + ", score=" + score + "]";
	}
	public int addScore(int score)throws IllegalScoreException{
		if(score>100||score<0)
			throw new IllegalScoreException("score out of range, score="+score);
		this.score=score;
		return score;
		
	}
	
}
public class Six_four {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
		try{
		while(scanner.hasNext()){
			try{
			String s = scanner.next();
			if(s.equals("new")){
				Student stu = new Student(scanner.next());
				stu.addScore(scanner.nextInt());
				System.out.println(stu);
			}
			else
				break;
			}catch(IllegalNameException e){
				System.out.println(e);
			}catch(IllegalScoreException e){
				System.out.println(e);
			}
		}
	}finally{
		System.out.println("scanner closed");
	}
		scanner.close();
	}
	

}